using System;
using FreshTexture.Enums;
using FreshTexture.Model;
using Microsoft.Win32;

namespace FreshTexture.ViewModel
{
    public class Commands
    {
        public void LoadCommand()
        {
            var dlg = new OpenFileDialog();

            bool? result = dlg.ShowDialog();

            if (result == true)
            {
                FileIO.LoadZip(new Uri(dlg.FileName, UriKind.RelativeOrAbsolute), MyEnums.DirsKeyWords.Source);
            }
        }

        public void SaveCommand()
        {
            throw new NotImplementedException();
        }

        public bool SaveCommandCanExecute()
        {
            bool result = false;
            foreach (Entity entity in ViewModelLocator.MainViewModel.DestinationTexturePack)
            {
                if (!entity.IsSaved)
                {
                    result = true;
                    break;
                }
            }

            return result;
        }


        public event EventHandler CanExecuteChanged;

        public void ExitCommand()
        {
            //todo Dodac okienko z pytaniem o zamkniecie aplikacji
            Environment.Exit(0);
        }
    }
}